package collection.homework.Demo4;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        ProductItem pi = new ProductItem();
        Set<ProductItem> pitSet1 = new TreeSet<>((o1, o2) -> o1.getOrderId() - o2.getOrderId());
        Random rd = new Random();
        ProductItem productItem1 = new ProductItem(1, rd.nextInt(100000000), 1, "酸奶", 50);
        ProductItem productItem2 = new ProductItem(2, rd.nextInt(100000000), 2, "手机", 5000);
        ProductItem productItem3 = new ProductItem(3, rd.nextInt(100000000), 3, "手机壳", 45);
        ProductItem productItem4 = new ProductItem(4, rd.nextInt(100000000), 4, "漱口水", 35);
        pitSet1.add(productItem1);
        pitSet1.add(productItem2);
        pitSet1.add(productItem3);
        pitSet1.add(productItem4);

        Set<ProductItem> pitSet2 = new TreeSet<>();
        ProductItem productItem5 = new ProductItem(1, rd.nextInt(100000000), 1, "可乐", 50);
        ProductItem productItem6 = new ProductItem(2, rd.nextInt(100000000), 2, "耳机", 5000);
        ProductItem productItem7 = new ProductItem(3, rd.nextInt(100000000), 3, "外套", 45);
        ProductItem productItem8 = new ProductItem(4, rd.nextInt(100000000), 4, "镜子", 35);
        pitSet2.add(productItem5);
        pitSet2.add(productItem6);
        pitSet2.add(productItem7);
        pitSet2.add(productItem8);


        Set<Set<ProductItem>> pits=new HashSet<>();
        pits.add(pitSet1);
        pits.add(pitSet2);

        for (Set<ProductItem> pit : pits) {
            pit.forEach(System.out::println);
            System.out.println("==========================");
        }
    }
}
